class GamesController < ApplicationController

  def index
	@upcoming_games = Game.upcoming_games
	@past_games = Game.past_games
  end
#new game
  def new
	@game = Game.new
  end
#show games
  def show
	@game = Game.find(params[:id])
  end
#create new games
  def create
	@game = Game.new(params[:game])
	if @game.save
	  flash[:notice] = 'Game Successfully Scheduled'
	  redirect_to :action => "index"
	else
	  render :action => "new"
	end
  end
#delete games
  def destroy
	@game = Game.find(params[:id])
 	@game.destroy

 	flash[:notice] = 'Game successfully cancelled'
 	redirect_to :action => "index"
  end
#edit games
  def update
	@game = Game.find(params[:id])

	if @game.update_attributes(params[:game])
	  flash[:notice] = 'Game successfully updated.'
	  redirect_to :action => "show", :id => params[:id]
	else
	  render :action => "edit"
	end
  end
#edit games
def edit
	@game= Game.find(params[:id])
  end

end
